package com.cake.liulanxiangzhu.controller;

import com.cake.liulanxiangzhu.pojo.dto.AdminPictureDTO;
import com.cake.liulanxiangzhu.pojo.dto.AdminPictureInsertDTO;
import com.cake.liulanxiangzhu.pojo.vo.AdminPictureVO;
import com.cake.liulanxiangzhu.service.AdminPictureService;
import com.cake.liulanxiangzhu.web.JsonPage;
import com.cake.liulanxiangzhu.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 图片(AdminPicture)表控制层
 *
 * @author DingHao
 * @since 2023-01-23 19:53:30
 */
@RestController
@RequestMapping("/adminPicture")
@Validated
public class AdminPictureController {
   @Autowired
   private AdminPictureService adminPictureService;

   @PostMapping("/addNew")
   public JsonResult<Void> addNew(@Validated AdminPictureInsertDTO adminPictureInsertDTO){
      adminPictureService.addNew(adminPictureInsertDTO);
      return JsonResult.ok();
   }

   @PostMapping("/remove")
   public JsonResult<Void> remove(Integer id){
      adminPictureService.deletePicture(id);
      return JsonResult.ok();
   }

   @PostMapping("/update")
   public JsonResult<Void> update(AdminPictureDTO adminPictureDTO){
      adminPictureService.updatePicture(adminPictureDTO);
      return JsonResult.ok();
   }

   @GetMapping("/queryList")
   public JsonResult<JsonPage<AdminPictureVO>> queryList(Integer page, Integer pageSize){
      JsonPage<AdminPictureVO> vos = adminPictureService.queryList(page, pageSize);
      return JsonResult.ok(vos);
   }

   @GetMapping("queryById")
   public JsonResult<AdminPictureVO> queryById(Integer id){
      AdminPictureVO adminPictureVO = adminPictureService.queryById(id);
      return JsonResult.ok(adminPictureVO);
   }
}

